package server;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Mapper {

    private Map<String, MappedContext> host = new HashMap<>();

    // 重名的不进行处理
    public void putMappedContext(String name, MappedContext mappedContext){
        if (host.get(name) == null){
            host.put(name, mappedContext);
        }
    }

    public MappedContext getMappedContext(String name){
        return host.get(name);
    }

    public static class MappedContext {
        private String contextUrl;
        private List<MappedWrapper> wrapperList;

        public MappedContext() {
            this.wrapperList = new ArrayList<>();
        }

        public String getContextUrl() {
            return contextUrl;
        }

        public void setContextUrl(String contextUrl) {
            this.contextUrl = contextUrl;
        }

        public List<MappedWrapper> getWrapperList() {
            return wrapperList;
        }

        public void setWrapperList(List<MappedWrapper> wrapperList) {
            this.wrapperList = wrapperList;
        }
    }

    public static class MappedWrapper{
        private String wrapperUrl;
        private String servletClass;
        private HttpServlet httpServlet;

        public String getServletClass() {
            return servletClass;
        }

        public void setServletClass(String servletClass) {
            this.servletClass = servletClass;
        }

        public HttpServlet getHttpServlet() {
            return httpServlet;
        }

        public void setHttpServlet(HttpServlet httpServlet) {
            this.httpServlet = httpServlet;
        }

        public String getWrapperUrl() {
            return wrapperUrl;
        }

        public void setWrapperUrl(String wrapperUrl) {
            this.wrapperUrl = wrapperUrl;
        }
    }

}


